<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>项目申报</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/static/css/buildUnit/common.css">
    <style>
        body {
            height: auto;
        }

        .content {
            padding: 20px;
        }

        .layui-container {
            padding-top: 20px;
            width: auto;;
        }

        /*单元格备注样式*/
        .layui-table td.tdBz {
            text-align: left;
            padding-left: 0;
            border-left: none;
            color: #aaa;
        }

        .padNone .layui-form-select .layui-input {
            padding-right: 0;
        }

        .hide {
            display: none;
        }
    </style>
</head>
<body>
<div class="layui-container">
    <form id="form" class="layui-form layui-form-pane" action="" lay-filter="example">
        <table class="layui-table v-table">
            <colgroup>
                <col width="24%">
                <col width="13%">
                <col width="13%">
                <col width="24%">
                <col width="13%">
                <col width="13%">
            </colgroup>
            <tbody>
            <tr>
                <td class="th8 required">工程担任角色</td>
                <td colspan="5">
                    <input type="hidden" name="decId" id="decId" class="formData">
                    <input type="hidden" name="personId" class="formData">
                    <input type="hidden" name="orgType" id="orgType" class="formData">
                    <select name="roleType" id="roleType" lay-filter="roleType" class="formData">
                        <option value="">请输入</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="th8 required">所属专业</td>
                <td colspan="5">
                    <select name="specialtyId" id="specialtyId" lay-filter="specialtyId" class="formData">
                        <option value="">请输入</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="th8 required">人员姓名</td>
                <td colspan="5">
                    <input type="text" autocomplete="off" class="layui-input selectBtn selectName formData"
                           name="userName"
                           placeholder="请选择">
                    <input type="hidden" class="layui-input selectId formData" name="userId" placeholder="请选择">
                </td>
            </tr>
            <tr>
                <td class="th8 required">人员证书信息</td>
                <td colspan="5">
                    <select class="formData" name="qualificationCertificateName" id="qualificationCertificateName"
                            lay-filter="qualificationCertificateName">
                        <option value="">请选择</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="th8 required">证书编码</td>
                <td colspan="5">
                    <input type="text" class="layui-input formData" name="qualificationCertificateNum"
                           id="qualificationCertificateNum" readonly>
                </td>
            </tr>
            <tr>
                <td class="th8 required">联系电话</td>
                <td colspan="5">
                    <input type="text" class="layui-input formData" name="linkPhone" placeholder="请输入">
                </td>
            </tr>
            </tbody>
        </table>
        <button lay-submit lay-filter="submit" style="display: none;" id="submit" class="demo1">提交</button>
    </form>
</div>
<script src="/static/js/main.js"></script>
<script type="text/javascript">
    layui.use(['jquery', 'element', 'form', 'laydate', 'configure', 'configureCom', 'jsDictFileStatic', 'selectFun', 'bluebird', 'replaceStr', 'jsDictFile', 'mapExtend'], function () {
        var element = layui.element;
        var form = layui.form;
        var configure = layui.configure;
        var configureCom = layui.configureCom;
        var laydate = layui.laydate;
        var jsDictFileStatic = layui.jsDictFileStatic;
        var selectFun = layui.selectFun;
        var sessionFun = layui.sessionFun;
        window.$ = layui.jquery;
        var specType = configureCom.GetQueryString('specType');//获取当前页面是勘察/设计打开
        var prjApplyData = sessionFun.get(configure.SESSION_PROJECT_WAIT_LIST_DATA); //项目申报数据
        var listData = sessionFun.get(configure.SESSION_KCSJ_REPORT_PEOPLE_LIST_DATA);  //勘察设计人员列表数据
        $('#decId').val(prjApplyData.decId);//将申报id放于隐藏域中
        var prjCategory = prjApplyData.prjCategory;//工程项目类别
        var specCode = '';//专业类别code
        var roleCode = '';//担任角色code
        if (specType == configure.KC_CODE) {
            specCode = configure.KC_SPE;
            roleCode = configure.KCDRJS;
        } else {
            roleCode = configure.SJDRJS;
            if (prjCategory == configure.PRJ_TYPE_FJ_CODE) {//如果工程项目类别为房建，则显示房建专业
                specCode = configure.FJ_SPE;
            } else {
                specCode = configure.SZ_SPE;
            }
        }
        $('#orgType').val(specType);//将勘察设计类型存入隐藏域
        if (listData) {
            configureCom.selectDataFun(roleCode, listData.roleType, '#roleType');//勘察担任角色
            configureCom.selectDataFun(specCode, listData.specialtyId, '#specialtyId');//专业类别
            getZizhiCert(listData.userId, listData.qualificationCertificateName);
        } else {
            configureCom.selectDataFun(roleCode, '', '#roleType');//勘察担任角色
            configureCom.selectDataFun(specCode, '', '#specialtyId');//专业类别
        }
        form.val('example', listData);

        $('#form').on('click', '.selectBtn', function () {
            var $this = $(this);
            var colsData = [[
                {type: 'radio'},
                {field: 'realName', title: '人员姓名'}
            ]];
            configureCom.childViewSelectFun('选择人员', colsData, configure.COM_ZIZHI_USER_ONJOB_LIST_HTTP).then(function (res) {
                if (res.length > 0) {
                    var childData = res[0];
                    $this.val(childData.realName);
                    $this.siblings('.selectId').val(childData.userId);
                    getZizhiCert(childData.userId);
                }
            });
        });

        function getZizhiCert(userId, targetVal) {
            configureCom.postDataAjax(configure.USER_ZIZHI_CERT_ALL_LIST_HTTP, {userId: userId}).then(function (res) {
                var zizhiList = res.page.records;
                configureCom.selectCustomDataFun(zizhiList, targetVal, '#qualificationCertificateName', 'aptitudeName', 'aptitudeName', 'aptitudeNumber');
            });
        }

        form.on('select(qualificationCertificateName)', function (data) {
            var type = $(data.elem).find('option:selected').attr('data-type');//证书编码
            $('#qualificationCertificateNum').val(type);
        });

        form.on('submit(submit)', function (data) {
            return false;
        });
    });

    function getData() {
        return new Promise(function (res, rej) {
            var data = {};
            if (!window.formVerifyFun()) {
                return false;
            }
            $('.formData').each(function (index, item) {
                if (!($(item).closest('tr').is(':hidden'))) {
                    var key = key = $(item).attr('name');
                    data[key] = $(item).val();
                }
            });
            res({result: data});
        });
    }

</script>
</body>
</html>
